//上传 进度 标志 对象
var modalWin;
var uploadRowIndex=-1;
efform_onload = function ()
{ 
	//页面加载的时候隐藏从表
	$('#ef_region_detail').hide();
	$('#ef_region_fileupload').hide();
	//创建 进度窗口
	modalWin  = new EFModalWindow('progressWindow'); 
	//给部门下拉框设置宽度，为了查询条件框对齐
//	$('#inqu_status-0-fdDepartmentId').css("width","140.8");
	
	if($('#fdDirId').val()!=null&&$('#fdDirId').val()!="")
	{
		$('#inqu_status-0-fdDirId').val($('#fdDirId').val()); 
	} 
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCD02","query"); 
};
button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCD02","query"); 
}
button_insert_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
	efgrid.submitForm( "ef_grid_r", "ZM","ZMCD02","insert",true);
}
button_update_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
	efgrid.submitForm( "ef_grid_r", "ZM","ZMCD02","update",true);
}
button_delete_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_r", "ZM","ZMCD02","delete",true);
	});
} 
button_release_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
	EFConfirm('你确认要发布吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_r", "ZM","ZMCD02","release",true);
	});
} 
efgrid_afterAddNewRow = function(grid_id){ 
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows(); 
	if(grid_id=="ef_grid_r")
	{
	   var fdCreatorId=$('#fdCreatorId').val(); 
	   var fdDepartmentId=$('#fdCreateDepartmentId').val(); 
	   
	   var now = new Date();
	   var year = now.getFullYear();       //年
	   var month = now.getMonth() + 1;     //月
	   var day = now.getDate();            //日 
	   var clock = year + "-";
	   if(month < 10) clock += "0";
	   clock += month + "-";
	   if(day < 10) clock += "0";
	   clock += day; 
	   
		for(var i = 0 ; i < rows.length;i++){ 
			grid.getBlockData().setCell(rows[i], "fdStatus", "草拟");
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
			grid.getBlockData().setCell(rows[i], "fdCreateDate", clock);
			grid.getBlockData().setCell(rows[i], "fdCreatorId", fdCreatorId);
			grid.getBlockData().setCell(rows[i], "fdDepartmentId", fdDepartmentId);
		}
	}
}
button_upload_onclick=function(){
	var grid=isSelected("ef_grid_r");
	if (grid == 0)return;
	var row_index=grid.getCheckedRowCount();
	var row=grid.getCheckedRows();
	if(row_index>1){
		EFAlert("只能选中一条项目信息后上传！");
		return;
	}
	var docId=grid.getCellValueByColumnName(row,"fdDocId");
	if(!isAvailable(docId)) {
		EFAlert("未指定文档号！", "系统警告");
		return false;
	}
	var url = "DispatchAction.do?efFormEname=EUAF3501";
		url = url + "&inqu_status-0-code=zm.cp";
	
	if(grid.getCellValueByColumnName(row,"fdStatus")!="0")
	{
		url = url + "&editFlag=0";
	}else{
		url = url + "&editFlag=1";
	}
	url = url + "&inqu_status-0-docId="+docId+"&time=" + new Date().getTime();
	
	EFColorbox({href:url,title:"附件管理",width:"80%", height:"80%", iframe:true});
}  

/**点击数据列的回调函数：当列类型为hyperlink或textbutton时点击有效 */
efgrid_onDataCellClick = function(grid_id, row_index, col_index, cell_value) {
	if (grid_id == "ef_grid_r") {		
		if (col_index == 5)
			efgrid_onRowClicked(grid_id, row_index);
			alert("11111");		  
//		 parent.document.mainFrame.location = "DispatchAction.do?efFormEname=ZMCP07&keyId="+keyId;		
//		 var childWindow = efform.openNewForm('ZMCH9001', "serviceName=ZMCH9001&methodName=query&keyId=" + keyId);
//		  childWindow.focus();	 	  
	}
}
